<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('日志列表')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">

<div class="container-div">
	<div class="row">

		<div class="col-sm-12 search-collapse">
			<form id="operlog-form">
				<div class="select-list">
					<ul>
						<li>
							<label>操作者： </label><input type="text" name="username" style="width: 150px"/>
						</li>
						<li>
							<label>请求url： </label><input type="text" name="query" style="width: 150px"/>
						</li>
						<li>
							日志类型：<select id="logType" name="logType" style="width: 100px" >
							<option value="">全部</option>
							<option value="1">成功日志</option>
							<option value="2">异常日志</option>
							</select>
						</li>
						<li>
							系统:
							<select id="interfaceType" name="interfaceType" style="width: 200px;" >
								<option value="1">后台系统</option>
							</select>
						</li>
						</li>
						<li class="select-time1">
							<label>操作时间： </label>
							<input type="text" class="time-input" style="width: 150px" id="startTime"   placeholder="开始时间" name="startTime"/>
							<span>-</span>
							<input type="text" class="time-input" style="width: 150px" id="endTime"  placeholder="结束时间" name="endTime"/>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="searchPre()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>


		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table"></table>
		</div>
	</div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />

<script th:inline="javascript">
	var editFlag ;
	var removeFlag ;
	var  detailFlag;
	var prefix = ctx + "sys/log";
	layui.use('laydate', function() {
		var laydate = layui.laydate;
		laydate.render({
			elem: '#startTime',
			type: 'datetime',
			trigger: 'click'
		});
		laydate.render({
			elem: '#endTime',
			type: 'datetime',
			trigger: 'click'
		});
	});




	$(function() {
		var options = {
			url: prefix + "/page",
			createUrl: prefix + "/index/add",
			updateUrl: prefix + "/index/edit?id={id}",
			removeUrl: prefix + "/deleteById",
			exportUrl: prefix + "/export",
			detailUrl: prefix + "/index/detail?id={id}",
			modalName: "日志",
			sortName: "createDate",
			sortOrder: "desc",
			method:"get",
			queryParams: queryParams,
			columns: [
				{
					field: 'requestDesc',
					title: '接口名称',
					align: 'center',
					formatter: function (value,row ,index) {
						return $.table.tooltip(value,10,value);
					}
				},
				{
					field: 'requestUrl',
					title: '请求url',
					align: 'center'
				},
				{
					field: 'methodType',
					title: '请求类型',
					align: 'center',
					formatter:function (value, row, index) {
						if (value==1){
							return "post";
						}else if (value==2){
							return "get";
						}
						return "未知";
					}
				},
				{
					field: 'requestIp',
					title: '请求ip',
					align: 'center'
				},{
					field: 'requestParam',
					title: '请求参数',
					align: 'center',
					formatter:function (value, row, index) {
						return $.table.tooltip(value,10,value)
					}
				},
				{
					field: 'exception',
					title: '报错日志',
					align: 'center',
					formatter:function (value, row, index) {
						return $.table.tooltip(value)
					}
				},
				{
					field: 'createName',
					title: '操作者',
					align: 'center'
				},
				{
					field: 'createDate',
					title: '创建时间',
					align: 'center'
				},
				{
					field: 'requestId',
					title: '日志Id',
					align: 'center'
				},
				{
					title: '操作',
					align: 'center',
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-search"></i>详细</a>');
						actions.push(' <a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
						return actions.join('');
					}
				}]
		};
		$.table.init(options);

	});


	/* 角色状态显示 */
	function statusTools(row) {
		if (row.status == 1) {
			return '开启';
		} else {
			return '关闭';
		}
	}

	function queryParams(params) {
		var search = $.table.queryParams(params);
		return search;
	}

	function searchPre() {
		$.table.search('operlog-form', 'bootstrap-table');
	}

	function resetPre() {
		$("#operlog-form")[0].reset();
		$.table.search('operlog-form', 'bootstrap-table');
	}

</script>
</body>
</html>
